/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fatec.controlecal;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

/**
 * @author gilberto
 */
public class HelloMIDlet extends MIDlet implements CommandListener {
    
    private Conexao categoriaConexao, alimentoConexao, refeiçãoConexao,configuracaoConexão;
    
    Categoria catBE[] = null;
    Vector aliBE;
    int currentIdCategoria;
    int currentIdAlimento;
    
    private int AICategoria;
    private int AIAlimento;
    private boolean midletPaused = false;
    private int totalCalorias = 0;
    
    private int metaDeCalorias;
    
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Command sairCommand;
    private Command addCategoriaCommand;
    private Command registrarRefeiçãoCommand;
    private Command voltarToInicialCommand;
    private Command salvarCategoriaCommand;
    private Command voltarListaToInicialCommand;
    private Command selecionarCategoriaCommand;
    private Command voltarToListaCategCommand;
    private Command detalhesAlimentoCommand;
    private Command NovoAlimentoCommand;
    private Command salvarNovoAlimentoCommand;
    private Command voltarToListaAlimentosCommand;
    private Command voltarEditarToListaCommand;
    private Command salvarEditarAlimentoCommand;
    private Command editarAlimentoCommand;
    private Command voltarDetalhesAlimentoCommand;
    private Command AddRefeiçãoCommand;
    private Command voltarDetalhesAlimentoCommand1;
    private Command salvarAddRefeicaoCommand;
    private Command voltarAddRefCommand;
    private Command ajudaCommand;
    private Command voltarAjudaCommand;
    private Command configuraçõesCommand;
    private Command voltarConfCommand;
    private Command salvarConfCommand;
    private Form Inicial;
    private StringItem totalPontosDiaStringItem;
    private Form addCategoria;
    private TextField nomeCategoriaTextField;
    private List listaCategoria;
    private List listaAlimentos;
    private Form novoAlimento;
    private TextField medidaAlimentoTextField;
    private TextField nomeAlimentoTextField;
    private TextField pesoAlimentoTextField;
    private TextField caloriasAlimentoTextField;
    private Form editarAlimento;
    private TextField nomeEditAlimentotextField;
    private TextField medidaEditAlimentotextField;
    private TextField pesoEditAlimentotextField;
    private TextField caloriasEditAlimentotextField;
    private List listaDetalhesAlimento;
    private Form addRefeição;
    private TextField qtdAlimentoRefeiçãotextField;
    private Form ajuda;
    private Form configurações;
    private TextField metaCaloriastextField;
//</editor-fold>//GEN-END:|fields|0|

    /**
     * The HelloMIDlet constructor.
     */
    public HelloMIDlet() {
        categoriaConexao = new Conexao("icategoria");
        alimentoConexao = new Conexao("alimento");
        refeiçãoConexao = new Conexao("refeição");
        configuracaoConexão = new Conexao("configuração");
        
        AICategoria = new Categoria().getAutoIncrement(categoriaConexao);
        System.out.println(AICategoria);
        Configuracao conf = new Configuracao();
        metaDeCalorias = conf.verifica(configuracaoConexão);
        
    }
    
    private void atualizarPontos(){
        Refeicao ref = new Refeicao();
        totalCalorias = ref.getPontos(refeiçãoConexao, Refeicao.REFEICAO_DO_DIA);
        totalPontosDiaStringItem.setText(totalCalorias+"");
    }
    
    private void carregarListaCategoria(List lista){
        lista.deleteAll();
        Categoria cat = new Categoria();
        Categoria[] categoria = cat.getCategorias(categoriaConexao);
        catBE = categoria;
        for(int i=0;i<categoria.length;i++){
            lista.append(categoria[i].getNome(), null);
        }
    }
    private void carregarListaAlimentos(List lista){
        lista.deleteAll();
        Alimento ali = new Alimento();
        System.out.println("atual"+lista.getSelectedIndex());
        System.out.println("fim"+lista.size());
        currentIdCategoria = catBE[listaCategoria.getSelectedIndex()].getId();
        Vector alimentosVector = ali.getAlimentos(alimentoConexao,ali.POR_CATEGORIA,currentIdCategoria);
        aliBE = alimentosVector;
        for(int i=0;i<alimentosVector.size();i++){
            Alimento almt = (Alimento)alimentosVector.elementAt(i);
            lista.append(almt.getNome(), null);
        }
    }
//        try{
//            conexão.abrirStore();
//            idsCategoria = new int[conexão.getStore().getNumRecords()];
//            int i=0;
//            RecordEnumeration re = conexão.getStore().enumerateRecords(null, null, false);
//            while(re.hasNextElement()){
//                int id = re.nextRecordId();
//                System.out.println(id);
//                ids[i++] = id;
//                byte bytes[] = conexão.getStore().getRecord(id);
//                ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
//                DataInputStream dis = new DataInputStream(bais);
//                String nome = dis.readUTF();
//                lista.append(nome, null);
//            }
//            conexão.fecharStore();
//        }catch(Exception ex){
//            ex.printStackTrace();
//        }
    
//    private void carregarLista(List lista, Conexao conexão){
//        lista.deleteAll();
//        try{
//            conexão.abrirStore();
//            idsCategoria = new int[conexão.getStore().getNumRecords()];
//            int i=0;
//            RecordEnumeration re = conexão.getStore().enumerateRecords(null, null, false);
//            while(re.hasNextElement()){
//                int id = re.nextRecordId();
//                System.out.println(id);
//                ids[i++] = id;
//                byte bytes[] = conexão.getStore().getRecord(id);
//                ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
//                DataInputStream dis = new DataInputStream(bais);
//                String nome = dis.readUTF();
//                lista.append(nome, null);
//            }
//            conexão.fecharStore();
//        }catch(Exception ex){
//            ex.printStackTrace();
//        }
//    }

//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initializes the application. It is called only once when the MIDlet is
     * started. The method is called before the
     * <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
//</editor-fold>//GEN-END:|0-initialize|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getInicial());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
        
    }//GEN-BEGIN:|3-startMIDlet|2|
//</editor-fold>//GEN-END:|3-startMIDlet|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
//</editor-fold>//GEN-END:|4-resumeMIDlet|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The
     * <code>display</code> instance is taken from
     * <code>getDisplay</code> method. This method is used by all actions in the
     * design for switching displayable.
     *
     * @param alert the Alert which is temporarily set to the display;
     * if <code>null</code>, then <code>nextDisplayable</code> is set
     * immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
//</editor-fold>//GEN-END:|5-switchDisplayable|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a
     * particular displayable.
     *
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == Inicial) {//GEN-BEGIN:|7-commandAction|1|23-preAction
            if (command == addCategoriaCommand) {//GEN-END:|7-commandAction|1|23-preAction
                // write pre-action user code here
                switchDisplayable(null, getAddCategoria());//GEN-LINE:|7-commandAction|2|23-postAction
                // write post-action user code here
            } else if (command == ajudaCommand) {//GEN-LINE:|7-commandAction|3|107-preAction
                // write pre-action user code here
                switchDisplayable(null, getAjuda());//GEN-LINE:|7-commandAction|4|107-postAction
                // write post-action user code here
            } else if (command == configuraçõesCommand) {//GEN-LINE:|7-commandAction|5|114-preAction
                // write pre-action user code here
                switchDisplayable(null, getConfigurações());//GEN-LINE:|7-commandAction|6|114-postAction
                // write post-action user code here
            } else if (command == registrarRefeiçãoCommand) {//GEN-LINE:|7-commandAction|7|25-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaCategoria());//GEN-LINE:|7-commandAction|8|25-postAction
                // write post-action user code here
                carregarListaCategoria(listaCategoria);
            } else if (command == sairCommand) {//GEN-LINE:|7-commandAction|9|19-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|10|19-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|11|30-preAction
        } else if (displayable == addCategoria) {
            if (command == salvarCategoriaCommand) {//GEN-END:|7-commandAction|11|30-preAction
                // write pre-action user code here
                Categoria categoria = new Categoria();
                categoria.setId(AIAlimento);
                categoria.setNome(nomeCategoriaTextField.getString());
                if(categoria.gravar(categoriaConexao,AICategoria)){
                    Alert sucesso = new Alert("Controle de Calorias");
                    sucesso.setString("Categoria de alimento salva com sucesso!");
                    sucesso.setTimeout(3000);
                    getDisplay().setCurrent(sucesso);
                    nomeCategoriaTextField.setString("");
                }
//                try{
//                    categoriaConexao.abrirStore();
//                    String nome = nomeCategoriaTextField.getString();
//                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
//                    DataOutputStream dos = new DataOutputStream(baos);
//                    dos.writeUTF(nome);
//                    byte bytes[] = baos.toByteArray();
//                    categoriaConexao.getStore().addRecord(bytes, 0, bytes.length);
//                    categoriaConexao.fecharStore();
//                    Alert sucesso = new Alert("Controle de Calorias");
//                    sucesso.setString("Categoria de alimento salva com sucesso!");
//                    sucesso.setTimeout(3000);
//                    getDisplay().setCurrent(sucesso);
//                    
//                    nomeCategoriaTextField.setString("");
//                }catch(Exception ex){
//                    ex.printStackTrace();
//                }
//GEN-LINE:|7-commandAction|12|30-postAction
                // write post-action user code here
            } else if (command == voltarToInicialCommand) {//GEN-LINE:|7-commandAction|13|28-preAction
                // write pre-action user code here
                switchDisplayable(null, getInicial());//GEN-LINE:|7-commandAction|14|28-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|15|104-preAction
        } else if (displayable == addRefeição) {
            if (command == salvarAddRefeicaoCommand) {//GEN-END:|7-commandAction|15|104-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|16|104-postAction
                // write post-action user code here
                Refeicao ref = new Refeicao();
                ref.setIdAlimento(currentIdAlimento);
                ref.setQuantidade(Integer.parseInt(qtdAlimentoRefeiçãotextField.getString()));
                Alimento ali = (Alimento)aliBE.elementAt(currentIdAlimento);
                if(totalCalorias+ref.getQuantidade()*ali.getCalorias() > metaDeCalorias){
                    Alert sucesso = new Alert("ControleCal - Controle de Calorias");
                    sucesso.setString("Operação não permitida: A meta de calorias diárias que é de "+metaDeCalorias+" com essa operação está sendo ultrapassada.");
                    sucesso.setTimeout(3000);
                    getDisplay().setCurrent(sucesso);
                    atualizarPontos();
                }else if(ref.addRefeição(refeiçãoConexao,(Alimento) aliBE.elementAt(currentIdAlimento), totalCalorias)){
                    Alert sucesso = new Alert("ControleCal - Controle de Calorias");
                    sucesso.setString("Refeição cadastrada com sucesso");
                    getDisplay().setCurrent(sucesso);
                    atualizarPontos();
                }
            } else if (command == voltarAddRefCommand) {//GEN-LINE:|7-commandAction|17|99-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaAlimentos());//GEN-LINE:|7-commandAction|18|99-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|19|111-preAction
        } else if (displayable == ajuda) {
            if (command == voltarAjudaCommand) {//GEN-END:|7-commandAction|19|111-preAction
                // write pre-action user code here
                switchDisplayable(null, getInicial());//GEN-LINE:|7-commandAction|20|111-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|21|123-preAction
        } else if (displayable == configurações) {
            if (command == salvarConfCommand) {//GEN-END:|7-commandAction|21|123-preAction
                // write pre-action user code here
                
//GEN-LINE:|7-commandAction|22|123-postAction
                // write post-action user code here
                Configuracao conf = new Configuracao();
                conf.setMetaDeCalorias(Integer.parseInt(metaCaloriastextField.getString()));
                if(conf.gravar(configuracaoConexão)){
                    Alert sucesso = new Alert("ControleCal - Controle de Calorias");
                    sucesso.setString("Refeição cadastrada com sucesso");
                    sucesso.setTimeout(3000);
                    getDisplay().setCurrent(sucesso);
                    metaDeCalorias = conf.getMetaDeCalorias();
                }
            } else if (command == voltarConfCommand) {//GEN-LINE:|7-commandAction|23|119-preAction
                // write pre-action user code here
                switchDisplayable(null, getInicial());//GEN-LINE:|7-commandAction|24|119-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|25|71-preAction
        } else if (displayable == editarAlimento) {
            if (command == salvarEditarAlimentoCommand) {//GEN-END:|7-commandAction|25|71-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|26|71-postAction
                // write post-action user code here
                Alimento ali = (Alimento)aliBE.elementAt(currentIdAlimento);
                if(ali.alterar(alimentoConexao)){
                    Alert sucesso = new Alert("ContrroleCal");
                    sucesso.setString("Alimento editado com sucesso");
                    sucesso.setTimeout(3000);
                    getDisplay().setCurrent(sucesso);
                                        
                }
            } else if (command == voltarEditarToListaCommand) {//GEN-LINE:|7-commandAction|27|69-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaAlimentos());//GEN-LINE:|7-commandAction|28|69-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|29|45-preAction
        } else if (displayable == listaAlimentos) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|29|45-preAction
                // write pre-action user code here
                listaAlimentosAction();//GEN-LINE:|7-commandAction|30|45-postAction
                // write post-action user code here
            } else if (command == NovoAlimentoCommand) {//GEN-LINE:|7-commandAction|31|54-preAction
                // write pre-action user code here
                switchDisplayable(null, getNovoAlimento());//GEN-LINE:|7-commandAction|32|54-postAction
                // write post-action user code here
            } else if (command == detalhesAlimentoCommand) {//GEN-LINE:|7-commandAction|33|52-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaDetalhesAlimento());//GEN-LINE:|7-commandAction|34|52-postAction
                // write post-action user code here
                Alimento ali = (Alimento)aliBE.elementAt(listaAlimentos.getSelectedIndex());
                Categoria cat = catBE[currentIdCategoria];
                listaDetalhesAlimento.append("Nome: "+ali.getNome(), null);
                listaDetalhesAlimento.append("Categoria: "+cat.getNome(), null);
                listaDetalhesAlimento.append("Medida: "+ali.getMedida(), null);
                listaDetalhesAlimento.append("Peso: "+ali.getPeso(), null);
                listaDetalhesAlimento.append("Calorias: "+ali.getCalorias(), null);
                
            } else if (command == editarAlimentoCommand) {//GEN-LINE:|7-commandAction|35|73-preAction
                // write pre-action user code here
                switchDisplayable(null, getEditarAlimento());//GEN-LINE:|7-commandAction|36|73-postAction
                // write post-action user code here
                Alimento ali = (Alimento)aliBE.elementAt(listaAlimentos.getSelectedIndex());
                nomeEditAlimentotextField.setString(ali.getNome());
                medidaEditAlimentotextField.setString(ali.getMedida());
                pesoEditAlimentotextField.setString(ali.getPeso());
                caloriasEditAlimentotextField.setString(ali.getCalorias()+"");
                
                
            } else if (command == voltarToListaCategCommand) {//GEN-LINE:|7-commandAction|37|48-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaCategoria());//GEN-LINE:|7-commandAction|38|48-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|39|36-preAction
        } else if (displayable == listaCategoria) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|39|36-preAction
                // write pre-action user code here
                listaCategoriaAction();//GEN-LINE:|7-commandAction|40|36-postAction
                // write post-action user code here
            } else if (command == selecionarCategoriaCommand) {//GEN-LINE:|7-commandAction|41|41-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaAlimentos());//GEN-LINE:|7-commandAction|42|41-postAction
                // write post-action user code here
                                
                carregarListaAlimentos(listaAlimentos);
                
            } else if (command == voltarListaToInicialCommand) {//GEN-LINE:|7-commandAction|43|39-preAction
                // write pre-action user code here
                switchDisplayable(null, getInicial());//GEN-LINE:|7-commandAction|44|39-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|45|95-preAction
        } else if (displayable == listaDetalhesAlimento) {
            if (command == AddRefeiçãoCommand) {//GEN-END:|7-commandAction|45|95-preAction
                // write pre-action user code here
                switchDisplayable(null, getAddRefeição());//GEN-LINE:|7-commandAction|46|95-postAction
                // write post-action user code here
                
            } else if (command == List.SELECT_COMMAND) {//GEN-LINE:|7-commandAction|47|88-preAction
                // write pre-action user code here
                listaDetalhesAlimentoAction();//GEN-LINE:|7-commandAction|48|88-postAction
                // write post-action user code here
            } else if (command == voltarDetalhesAlimentoCommand1) {//GEN-LINE:|7-commandAction|49|91-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaAlimentos());//GEN-LINE:|7-commandAction|50|91-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|51|59-preAction
        } else if (displayable == novoAlimento) {
            if (command == salvarNovoAlimentoCommand) {//GEN-END:|7-commandAction|51|59-preAction
                // write pre-action user code here
//GEN-LINE:|7-commandAction|52|59-postAction
                // write post-action user code here
                Alimento ali = new Alimento();
                ali.setNome(nomeAlimentoTextField.getString());
                ali.setIdCategoria(currentIdCategoria);
                ali.setMedida(medidaAlimentoTextField.getString());
                ali.setPeso(pesoAlimentoTextField.getString());
                ali.setCalorias(Integer.parseInt(caloriasAlimentoTextField.getString()));
                
                if(ali.gravar(alimentoConexao, AIAlimento)){
                    Alert sucesso = new Alert("ControleCal - Controle de Calorias");
                    sucesso.setString("Alimento adicionado com sucesso!");
                    sucesso.setTimeout(3000);
                    getDisplay().setCurrent(sucesso);
                    
                    nomeAlimentoTextField.setString("");
                    medidaAlimentoTextField.setString("");
                    pesoAlimentoTextField.setString("");
                    caloriasAlimentoTextField.setString("");
                    
                }
                
            } else if (command == voltarToListaAlimentosCommand) {//GEN-LINE:|7-commandAction|53|57-preAction
                // write pre-action user code here
                switchDisplayable(null, getListaAlimentos());//GEN-LINE:|7-commandAction|54|57-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|55|7-postCommandAction
        }//GEN-END:|7-commandAction|55|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|56|
//</editor-fold>//GEN-END:|7-commandAction|56|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: sairCommand ">//GEN-BEGIN:|18-getter|0|18-preInit
    /**
     * Returns an initialized instance of sairCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSairCommand() {
        if (sairCommand == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
            sairCommand = new Command("Sair", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
            // write post-init user code here
        }//GEN-BEGIN:|18-getter|2|
        return sairCommand;
    }
//</editor-fold>//GEN-END:|18-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: Inicial ">//GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initialized instance of Inicial component.
     *
     * @return the initialized component instance
     */
    public Form getInicial() {
        if (Inicial == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            Inicial = new Form("Welcome", new Item[]{getTotalPontosDiaStringItem()});//GEN-BEGIN:|14-getter|1|14-postInit
            Inicial.addCommand(getSairCommand());
            Inicial.addCommand(getAddCategoriaCommand());
            Inicial.addCommand(getRegistrarRefeiçãoCommand());
            Inicial.addCommand(getAjudaCommand());
            Inicial.addCommand(getConfiguraçõesCommand());
            Inicial.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
            atualizarPontos();
        }//GEN-BEGIN:|14-getter|2|
        return Inicial;
    }
//</editor-fold>//GEN-END:|14-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: totalPontosDiaStringItem ">//GEN-BEGIN:|16-getter|0|16-preInit
    /**
     * Returns an initialized instance of totalPontosDiaStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getTotalPontosDiaStringItem() {
        if (totalPontosDiaStringItem == null) {//GEN-END:|16-getter|0|16-preInit
            // write pre-init user code here
            totalPontosDiaStringItem = new StringItem("Total dePontos:", "");//GEN-LINE:|16-getter|1|16-postInit
            // write post-init user code here
        }//GEN-BEGIN:|16-getter|2|
        return totalPontosDiaStringItem;
    }
//</editor-fold>//GEN-END:|16-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: addCategoriaCommand ">//GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initialized instance of addCategoriaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getAddCategoriaCommand() {
        if (addCategoriaCommand == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            addCategoriaCommand = new Command("Adicionar Categoria", Command.ITEM, 0);//GEN-LINE:|22-getter|1|22-postInit
            // write post-init user code here
        }//GEN-BEGIN:|22-getter|2|
        return addCategoriaCommand;
    }
//</editor-fold>//GEN-END:|22-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: registrarRefeiçãoCommand ">//GEN-BEGIN:|24-getter|0|24-preInit
    /**
     * Returns an initialized instance of registrarRefeiçãoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getRegistrarRefeiçãoCommand() {
        if (registrarRefeiçãoCommand == null) {//GEN-END:|24-getter|0|24-preInit
            // write pre-init user code here
            registrarRefeiçãoCommand = new Command("Listar ou Adicionar Alimetos", Command.ITEM, 0);//GEN-LINE:|24-getter|1|24-postInit
            // write post-init user code here
        }//GEN-BEGIN:|24-getter|2|
        return registrarRefeiçãoCommand;
    }
//</editor-fold>//GEN-END:|24-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarToInicialCommand ">//GEN-BEGIN:|27-getter|0|27-preInit
    /**
     * Returns an initialized instance of voltarToInicialCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarToInicialCommand() {
        if (voltarToInicialCommand == null) {//GEN-END:|27-getter|0|27-preInit
            // write pre-init user code here
            voltarToInicialCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|27-getter|1|27-postInit
            // write post-init user code here
        }//GEN-BEGIN:|27-getter|2|
        return voltarToInicialCommand;
    }
//</editor-fold>//GEN-END:|27-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: salvarCategoriaCommand ">//GEN-BEGIN:|29-getter|0|29-preInit
    /**
     * Returns an initialized instance of salvarCategoriaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSalvarCategoriaCommand() {
        if (salvarCategoriaCommand == null) {//GEN-END:|29-getter|0|29-preInit
            // write pre-init user code here
            salvarCategoriaCommand = new Command("Salvar", Command.ITEM, 0);//GEN-LINE:|29-getter|1|29-postInit
            // write post-init user code here
        }//GEN-BEGIN:|29-getter|2|
        return salvarCategoriaCommand;
    }
//</editor-fold>//GEN-END:|29-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: addCategoria ">//GEN-BEGIN:|26-getter|0|26-preInit
    /**
     * Returns an initialized instance of addCategoria component.
     *
     * @return the initialized component instance
     */
    public Form getAddCategoria() {
        if (addCategoria == null) {//GEN-END:|26-getter|0|26-preInit
            // write pre-init user code here
            addCategoria = new Form("Nova Categoria", new Item[]{getNomeCategoriaTextField()});//GEN-BEGIN:|26-getter|1|26-postInit
            addCategoria.addCommand(getVoltarToInicialCommand());
            addCategoria.addCommand(getSalvarCategoriaCommand());
            addCategoria.setCommandListener(this);//GEN-END:|26-getter|1|26-postInit
            // write post-init user code here
        }//GEN-BEGIN:|26-getter|2|
        return addCategoria;
    }
//</editor-fold>//GEN-END:|26-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: nomeCategoriaTextField ">//GEN-BEGIN:|33-getter|0|33-preInit
    /**
     * Returns an initialized instance of nomeCategoriaTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getNomeCategoriaTextField() {
        if (nomeCategoriaTextField == null) {//GEN-END:|33-getter|0|33-preInit
            // write pre-init user code here
            nomeCategoriaTextField = new TextField("Nome da Categoria:", "", 32, TextField.ANY);//GEN-LINE:|33-getter|1|33-postInit
            // write post-init user code here
        }//GEN-BEGIN:|33-getter|2|
        return nomeCategoriaTextField;
    }
//</editor-fold>//GEN-END:|33-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarListaToInicialCommand ">//GEN-BEGIN:|38-getter|0|38-preInit
    /**
     * Returns an initialized instance of voltarListaToInicialCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarListaToInicialCommand() {
        if (voltarListaToInicialCommand == null) {//GEN-END:|38-getter|0|38-preInit
            // write pre-init user code here
            voltarListaToInicialCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|38-getter|1|38-postInit
            // write post-init user code here
        }//GEN-BEGIN:|38-getter|2|
        return voltarListaToInicialCommand;
    }
//</editor-fold>//GEN-END:|38-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: selecionarCategoriaCommand ">//GEN-BEGIN:|40-getter|0|40-preInit
    /**
     * Returns an initialized instance of selecionarCategoriaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSelecionarCategoriaCommand() {
        if (selecionarCategoriaCommand == null) {//GEN-END:|40-getter|0|40-preInit
            // write pre-init user code here
            selecionarCategoriaCommand = new Command("Selecionar", Command.ITEM, 0);//GEN-LINE:|40-getter|1|40-postInit
            // write post-init user code here
        }//GEN-BEGIN:|40-getter|2|
        return selecionarCategoriaCommand;
    }
//</editor-fold>//GEN-END:|40-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: listaCategoria ">//GEN-BEGIN:|34-getter|0|34-preInit
    /**
     * Returns an initialized instance of listaCategoria component.
     *
     * @return the initialized component instance
     */
    public List getListaCategoria() {
        if (listaCategoria == null) {//GEN-END:|34-getter|0|34-preInit
            // write pre-init user code here
            listaCategoria = new List("Nova Refei\u00E7\u00E3o - Escolha o Tipo", Choice.IMPLICIT);//GEN-BEGIN:|34-getter|1|34-postInit
            listaCategoria.addCommand(getVoltarListaToInicialCommand());
            listaCategoria.addCommand(getSelecionarCategoriaCommand());
            listaCategoria.setCommandListener(this);//GEN-END:|34-getter|1|34-postInit
            // write post-init user code here
        }//GEN-BEGIN:|34-getter|2|
        return listaCategoria;
    }
//</editor-fold>//GEN-END:|34-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: listaCategoriaAction ">//GEN-BEGIN:|34-action|0|34-preAction
    /**
     * Performs an action assigned to the selected list element in the
     * listaCategoria component.
     */
    public void listaCategoriaAction() {//GEN-END:|34-action|0|34-preAction
        // enter pre-action user code here
        String __selectedString = getListaCategoria().getString(getListaCategoria().getSelectedIndex());//GEN-LINE:|34-action|1|34-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|34-action|2|
//</editor-fold>//GEN-END:|34-action|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarToListaCategCommand ">//GEN-BEGIN:|47-getter|0|47-preInit
    /**
     * Returns an initialized instance of voltarToListaCategCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarToListaCategCommand() {
        if (voltarToListaCategCommand == null) {//GEN-END:|47-getter|0|47-preInit
            // write pre-init user code here
            voltarToListaCategCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|47-getter|1|47-postInit
            // write post-init user code here
        }//GEN-BEGIN:|47-getter|2|
        return voltarToListaCategCommand;
    }
//</editor-fold>//GEN-END:|47-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: listaAlimentos ">//GEN-BEGIN:|44-getter|0|44-preInit
    /**
     * Returns an initialized instance of listaAlimentos component.
     *
     * @return the initialized component instance
     */
    public List getListaAlimentos() {
        if (listaAlimentos == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
            listaAlimentos = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|44-getter|1|44-postInit
            listaAlimentos.addCommand(getVoltarToListaCategCommand());
            listaAlimentos.addCommand(getDetalhesAlimentoCommand());
            listaAlimentos.addCommand(getNovoAlimentoCommand());
            listaAlimentos.addCommand(getEditarAlimentoCommand());
            listaAlimentos.setCommandListener(this);//GEN-END:|44-getter|1|44-postInit
            // write post-init user code here
        }//GEN-BEGIN:|44-getter|2|
        return listaAlimentos;
    }
//</editor-fold>//GEN-END:|44-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: listaAlimentosAction ">//GEN-BEGIN:|44-action|0|44-preAction
    /**
     * Performs an action assigned to the selected list element in the
     * listaAlimentos component.
     */
    public void listaAlimentosAction() {//GEN-END:|44-action|0|44-preAction
        // enter pre-action user code here
        String __selectedString = getListaAlimentos().getString(getListaAlimentos().getSelectedIndex());//GEN-LINE:|44-action|1|44-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|44-action|2|
//</editor-fold>//GEN-END:|44-action|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: detalhesAlimentoCommand ">//GEN-BEGIN:|51-getter|0|51-preInit
    /**
     * Returns an initialized instance of detalhesAlimentoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getDetalhesAlimentoCommand() {
        if (detalhesAlimentoCommand == null) {//GEN-END:|51-getter|0|51-preInit
            // write pre-init user code here
            detalhesAlimentoCommand = new Command("Detalhes", Command.ITEM, 0);//GEN-LINE:|51-getter|1|51-postInit
            // write post-init user code here
        }//GEN-BEGIN:|51-getter|2|
        return detalhesAlimentoCommand;
    }
//</editor-fold>//GEN-END:|51-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: NovoAlimentoCommand ">//GEN-BEGIN:|53-getter|0|53-preInit
    /**
     * Returns an initialized instance of NovoAlimentoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getNovoAlimentoCommand() {
        if (NovoAlimentoCommand == null) {//GEN-END:|53-getter|0|53-preInit
            // write pre-init user code here
            NovoAlimentoCommand = new Command("Novo Alimento", Command.ITEM, 0);//GEN-LINE:|53-getter|1|53-postInit
            // write post-init user code here
        }//GEN-BEGIN:|53-getter|2|
        return NovoAlimentoCommand;
    }
//</editor-fold>//GEN-END:|53-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarToListaAlimentosCommand ">//GEN-BEGIN:|56-getter|0|56-preInit
    /**
     * Returns an initialized instance of voltarToListaAlimentosCommand
     * component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarToListaAlimentosCommand() {
        if (voltarToListaAlimentosCommand == null) {//GEN-END:|56-getter|0|56-preInit
            // write pre-init user code here
            voltarToListaAlimentosCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|56-getter|1|56-postInit
            // write post-init user code here
        }//GEN-BEGIN:|56-getter|2|
        return voltarToListaAlimentosCommand;
    }
//</editor-fold>//GEN-END:|56-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: salvarNovoAlimentoCommand ">//GEN-BEGIN:|58-getter|0|58-preInit
    /**
     * Returns an initialized instance of salvarNovoAlimentoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSalvarNovoAlimentoCommand() {
        if (salvarNovoAlimentoCommand == null) {//GEN-END:|58-getter|0|58-preInit
            // write pre-init user code here
            salvarNovoAlimentoCommand = new Command("Ok", Command.ITEM, 0);//GEN-LINE:|58-getter|1|58-postInit
            // write post-init user code here
        }//GEN-BEGIN:|58-getter|2|
        return salvarNovoAlimentoCommand;
    }
//</editor-fold>//GEN-END:|58-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: novoAlimento ">//GEN-BEGIN:|55-getter|0|55-preInit
    /**
     * Returns an initialized instance of novoAlimento component.
     *
     * @return the initialized component instance
     */
    public Form getNovoAlimento() {
        if (novoAlimento == null) {//GEN-END:|55-getter|0|55-preInit
            // write pre-init user code here
            novoAlimento = new Form("Novo Alimento", new Item[]{getNomeAlimentoTextField(), getMedidaAlimentoTextField(), getPesoAlimentoTextField(), getCaloriasAlimentoTextField()});//GEN-BEGIN:|55-getter|1|55-postInit
            novoAlimento.addCommand(getVoltarToListaAlimentosCommand());
            novoAlimento.addCommand(getSalvarNovoAlimentoCommand());
            novoAlimento.setCommandListener(this);//GEN-END:|55-getter|1|55-postInit
            // write post-init user code here
        }//GEN-BEGIN:|55-getter|2|
        return novoAlimento;
    }
//</editor-fold>//GEN-END:|55-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: nomeAlimentoTextField ">//GEN-BEGIN:|62-getter|0|62-preInit
    /**
     * Returns an initialized instance of nomeAlimentoTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getNomeAlimentoTextField() {
        if (nomeAlimentoTextField == null) {//GEN-END:|62-getter|0|62-preInit
            // write pre-init user code here
            nomeAlimentoTextField = new TextField("Nome:", "", 32, TextField.ANY);//GEN-LINE:|62-getter|1|62-postInit
            // write post-init user code here
        }//GEN-BEGIN:|62-getter|2|
        return nomeAlimentoTextField;
    }
//</editor-fold>//GEN-END:|62-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: medidaAlimentoTextField ">//GEN-BEGIN:|63-getter|0|63-preInit
    /**
     * Returns an initialized instance of medidaAlimentoTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getMedidaAlimentoTextField() {
        if (medidaAlimentoTextField == null) {//GEN-END:|63-getter|0|63-preInit
            // write pre-init user code here
            medidaAlimentoTextField = new TextField("Medida:", "", 32, TextField.ANY);//GEN-LINE:|63-getter|1|63-postInit
            // write post-init user code here
        }//GEN-BEGIN:|63-getter|2|
        return medidaAlimentoTextField;
    }
//</editor-fold>//GEN-END:|63-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pesoAlimentoTextField ">//GEN-BEGIN:|64-getter|0|64-preInit
    /**
     * Returns an initialized instance of pesoAlimentoTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getPesoAlimentoTextField() {
        if (pesoAlimentoTextField == null) {//GEN-END:|64-getter|0|64-preInit
            // write pre-init user code here
            pesoAlimentoTextField = new TextField("Peso:", "", 32, TextField.ANY);//GEN-LINE:|64-getter|1|64-postInit
            // write post-init user code here
        }//GEN-BEGIN:|64-getter|2|
        return pesoAlimentoTextField;
    }
//</editor-fold>//GEN-END:|64-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: caloriasAlimentoTextField ">//GEN-BEGIN:|65-getter|0|65-preInit
    /**
     * Returns an initialized instance of caloriasAlimentoTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getCaloriasAlimentoTextField() {
        if (caloriasAlimentoTextField == null) {//GEN-END:|65-getter|0|65-preInit
            // write pre-init user code here
            caloriasAlimentoTextField = new TextField("Calorias:", "", 32, TextField.NUMERIC);//GEN-LINE:|65-getter|1|65-postInit
            // write post-init user code here
        }//GEN-BEGIN:|65-getter|2|
        return caloriasAlimentoTextField;
    }
//</editor-fold>//GEN-END:|65-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarEditarToListaCommand ">//GEN-BEGIN:|68-getter|0|68-preInit
    /**
     * Returns an initialized instance of voltarEditarToListaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarEditarToListaCommand() {
        if (voltarEditarToListaCommand == null) {//GEN-END:|68-getter|0|68-preInit
            // write pre-init user code here
            voltarEditarToListaCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|68-getter|1|68-postInit
            // write post-init user code here
        }//GEN-BEGIN:|68-getter|2|
        return voltarEditarToListaCommand;
    }
//</editor-fold>//GEN-END:|68-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: salvarEditarAlimentoCommand ">//GEN-BEGIN:|70-getter|0|70-preInit
    /**
     * Returns an initialized instance of salvarEditarAlimentoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSalvarEditarAlimentoCommand() {
        if (salvarEditarAlimentoCommand == null) {//GEN-END:|70-getter|0|70-preInit
            // write pre-init user code here
            salvarEditarAlimentoCommand = new Command("Ok", Command.ITEM, 0);//GEN-LINE:|70-getter|1|70-postInit
            // write post-init user code here
        }//GEN-BEGIN:|70-getter|2|
        return salvarEditarAlimentoCommand;
    }
//</editor-fold>//GEN-END:|70-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: editarAlimentoCommand ">//GEN-BEGIN:|72-getter|0|72-preInit
    /**
     * Returns an initialized instance of editarAlimentoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getEditarAlimentoCommand() {
        if (editarAlimentoCommand == null) {//GEN-END:|72-getter|0|72-preInit
            // write pre-init user code here
            editarAlimentoCommand = new Command("Editar", Command.ITEM, 0);//GEN-LINE:|72-getter|1|72-postInit
            // write post-init user code here
        }//GEN-BEGIN:|72-getter|2|
        return editarAlimentoCommand;
    }
//</editor-fold>//GEN-END:|72-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: editarAlimento ">//GEN-BEGIN:|67-getter|0|67-preInit
    /**
     * Returns an initialized instance of editarAlimento component.
     *
     * @return the initialized component instance
     */
    public Form getEditarAlimento() {
        if (editarAlimento == null) {//GEN-END:|67-getter|0|67-preInit
            // write pre-init user code here
            editarAlimento = new Form("form", new Item[]{getNomeEditAlimentotextField(), getMedidaEditAlimentotextField(), getPesoEditAlimentotextField(), getCaloriasEditAlimentotextField()});//GEN-BEGIN:|67-getter|1|67-postInit
            editarAlimento.addCommand(getVoltarEditarToListaCommand());
            editarAlimento.addCommand(getSalvarEditarAlimentoCommand());
            editarAlimento.setCommandListener(this);//GEN-END:|67-getter|1|67-postInit
            // write post-init user code here
        }//GEN-BEGIN:|67-getter|2|
        return editarAlimento;
    }
//</editor-fold>//GEN-END:|67-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: nomeEditAlimentotextField ">//GEN-BEGIN:|76-getter|0|76-preInit
    /**
     * Returns an initialized instance of nomeEditAlimentotextField component.
     *
     * @return the initialized component instance
     */
    public TextField getNomeEditAlimentotextField() {
        if (nomeEditAlimentotextField == null) {//GEN-END:|76-getter|0|76-preInit
            // write pre-init user code here
            nomeEditAlimentotextField = new TextField("nome:", "", 32, TextField.ANY);//GEN-LINE:|76-getter|1|76-postInit
            // write post-init user code here
        }//GEN-BEGIN:|76-getter|2|
        return nomeEditAlimentotextField;
    }
//</editor-fold>//GEN-END:|76-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: medidaEditAlimentotextField ">//GEN-BEGIN:|77-getter|0|77-preInit
    /**
     * Returns an initialized instance of medidaEditAlimentotextField component.
     *
     * @return the initialized component instance
     */
    public TextField getMedidaEditAlimentotextField() {
        if (medidaEditAlimentotextField == null) {//GEN-END:|77-getter|0|77-preInit
            // write pre-init user code here
            medidaEditAlimentotextField = new TextField("medida:", "", 32, TextField.ANY);//GEN-LINE:|77-getter|1|77-postInit
            // write post-init user code here
        }//GEN-BEGIN:|77-getter|2|
        return medidaEditAlimentotextField;
    }
//</editor-fold>//GEN-END:|77-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pesoEditAlimentotextField ">//GEN-BEGIN:|78-getter|0|78-preInit
    /**
     * Returns an initialized instance of pesoEditAlimentotextField component.
     *
     * @return the initialized component instance
     */
    public TextField getPesoEditAlimentotextField() {
        if (pesoEditAlimentotextField == null) {//GEN-END:|78-getter|0|78-preInit
            // write pre-init user code here
            pesoEditAlimentotextField = new TextField("peso:", "", 32, TextField.ANY);//GEN-LINE:|78-getter|1|78-postInit
            // write post-init user code here
        }//GEN-BEGIN:|78-getter|2|
        return pesoEditAlimentotextField;
    }
//</editor-fold>//GEN-END:|78-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: caloriasEditAlimentotextField ">//GEN-BEGIN:|79-getter|0|79-preInit
    /**
     * Returns an initialized instance of caloriasEditAlimentotextField
     * component.
     *
     * @return the initialized component instance
     */
    public TextField getCaloriasEditAlimentotextField() {
        if (caloriasEditAlimentotextField == null) {//GEN-END:|79-getter|0|79-preInit
            // write pre-init user code here
            caloriasEditAlimentotextField = new TextField("calorias:", "", 32, TextField.ANY);//GEN-LINE:|79-getter|1|79-postInit
            // write post-init user code here
        }//GEN-BEGIN:|79-getter|2|
        return caloriasEditAlimentotextField;
    }
//</editor-fold>//GEN-END:|79-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarDetalhesAlimentoCommand ">//GEN-BEGIN:|82-getter|0|82-preInit
    /**
     * Returns an initialized instance of voltarDetalhesAlimentoCommand
     * component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarDetalhesAlimentoCommand() {
        if (voltarDetalhesAlimentoCommand == null) {//GEN-END:|82-getter|0|82-preInit
            // write pre-init user code here
            voltarDetalhesAlimentoCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|82-getter|1|82-postInit
            // write post-init user code here
        }//GEN-BEGIN:|82-getter|2|
        return voltarDetalhesAlimentoCommand;
    }
//</editor-fold>//GEN-END:|82-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarDetalhesAlimentoCommand1 ">//GEN-BEGIN:|90-getter|0|90-preInit
    /**
     * Returns an initialized instance of voltarDetalhesAlimentoCommand1
     * component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarDetalhesAlimentoCommand1() {
        if (voltarDetalhesAlimentoCommand1 == null) {//GEN-END:|90-getter|0|90-preInit
            // write pre-init user code here
            voltarDetalhesAlimentoCommand1 = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|90-getter|1|90-postInit
            // write post-init user code here
        }//GEN-BEGIN:|90-getter|2|
        return voltarDetalhesAlimentoCommand1;
    }
//</editor-fold>//GEN-END:|90-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: listaDetalhesAlimento ">//GEN-BEGIN:|87-getter|0|87-preInit
    /**
     * Returns an initialized instance of listaDetalhesAlimento component.
     *
     * @return the initialized component instance
     */
    public List getListaDetalhesAlimento() {
        if (listaDetalhesAlimento == null) {//GEN-END:|87-getter|0|87-preInit
            // write pre-init user code here
            listaDetalhesAlimento = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|87-getter|1|87-postInit
            listaDetalhesAlimento.addCommand(getVoltarDetalhesAlimentoCommand1());
            listaDetalhesAlimento.addCommand(getAddRefeiçãoCommand());
            listaDetalhesAlimento.setCommandListener(this);//GEN-END:|87-getter|1|87-postInit
            // write post-init user code here
        }//GEN-BEGIN:|87-getter|2|
        return listaDetalhesAlimento;
    }
//</editor-fold>//GEN-END:|87-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: listaDetalhesAlimentoAction ">//GEN-BEGIN:|87-action|0|87-preAction
    /**
     * Performs an action assigned to the selected list element in the
     * listaDetalhesAlimento component.
     */
    public void listaDetalhesAlimentoAction() {//GEN-END:|87-action|0|87-preAction
        // enter pre-action user code here
        String __selectedString = getListaDetalhesAlimento().getString(getListaDetalhesAlimento().getSelectedIndex());//GEN-LINE:|87-action|1|87-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|87-action|2|
//</editor-fold>//GEN-END:|87-action|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: AddRefeiçãoCommand ">//GEN-BEGIN:|94-getter|0|94-preInit
    /**
     * Returns an initialized instance of AddRefeiçãoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getAddRefeiçãoCommand() {
        if (AddRefeiçãoCommand == null) {//GEN-END:|94-getter|0|94-preInit
            // write pre-init user code here
            AddRefeiçãoCommand = new Command("Adicionar Refei\u00E7\u00E3o", Command.ITEM, 0);//GEN-LINE:|94-getter|1|94-postInit
            // write post-init user code here
        }//GEN-BEGIN:|94-getter|2|
        return AddRefeiçãoCommand;
    }
//</editor-fold>//GEN-END:|94-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: addRefeição ">//GEN-BEGIN:|96-getter|0|96-preInit
    /**
     * Returns an initialized instance of addRefeição component.
     *
     * @return the initialized component instance
     */
    public Form getAddRefeição() {
        if (addRefeição == null) {//GEN-END:|96-getter|0|96-preInit
            // write pre-init user code here
            addRefeição = new Form("form", new Item[]{getQtdAlimentoRefeiçãotextField()});//GEN-BEGIN:|96-getter|1|96-postInit
            addRefeição.addCommand(getVoltarAddRefCommand());
            addRefeição.addCommand(getSalvarAddRefeicaoCommand());
            addRefeição.setCommandListener(this);//GEN-END:|96-getter|1|96-postInit
            // write post-init user code here
        }//GEN-BEGIN:|96-getter|2|
        return addRefeição;
    }
//</editor-fold>//GEN-END:|96-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarAddRefCommand ">//GEN-BEGIN:|98-getter|0|98-preInit
    /**
     * Returns an initialized instance of voltarAddRefCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarAddRefCommand() {
        if (voltarAddRefCommand == null) {//GEN-END:|98-getter|0|98-preInit
            // write pre-init user code here
            voltarAddRefCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|98-getter|1|98-postInit
            // write post-init user code here
        }//GEN-BEGIN:|98-getter|2|
        return voltarAddRefCommand;
    }
//</editor-fold>//GEN-END:|98-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: salvarAddRefeicaoCommand ">//GEN-BEGIN:|103-getter|0|103-preInit
    /**
     * Returns an initialized instance of salvarAddRefeicaoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSalvarAddRefeicaoCommand() {
        if (salvarAddRefeicaoCommand == null) {//GEN-END:|103-getter|0|103-preInit
            // write pre-init user code here
            salvarAddRefeicaoCommand = new Command("Ok", Command.ITEM, 0);//GEN-LINE:|103-getter|1|103-postInit
            // write post-init user code here
        }//GEN-BEGIN:|103-getter|2|
        return salvarAddRefeicaoCommand;
    }
//</editor-fold>//GEN-END:|103-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: qtdAlimentoRefeiçãotextField ">//GEN-BEGIN:|105-getter|0|105-preInit
    /**
     * Returns an initialized instance of qtdAlimentoRefeiçãotextField
     * component.
     *
     * @return the initialized component instance
     */
    public TextField getQtdAlimentoRefeiçãotextField() {
        if (qtdAlimentoRefeiçãotextField == null) {//GEN-END:|105-getter|0|105-preInit
            // write pre-init user code here
            qtdAlimentoRefeiçãotextField = new TextField("Digite a quantidade:", "1", 32, TextField.NUMERIC);//GEN-LINE:|105-getter|1|105-postInit
            // write post-init user code here
        }//GEN-BEGIN:|105-getter|2|
        return qtdAlimentoRefeiçãotextField;
    }
//</editor-fold>//GEN-END:|105-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: ajudaCommand ">//GEN-BEGIN:|106-getter|0|106-preInit
    /**
     * Returns an initialized instance of ajudaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getAjudaCommand() {
        if (ajudaCommand == null) {//GEN-END:|106-getter|0|106-preInit
            // write pre-init user code here
            ajudaCommand = new Command("Ajuda", Command.ITEM, 0);//GEN-LINE:|106-getter|1|106-postInit
            // write post-init user code here
        }//GEN-BEGIN:|106-getter|2|
        return ajudaCommand;
    }
//</editor-fold>//GEN-END:|106-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarAjudaCommand ">//GEN-BEGIN:|110-getter|0|110-preInit
    /**
     * Returns an initialized instance of voltarAjudaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarAjudaCommand() {
        if (voltarAjudaCommand == null) {//GEN-END:|110-getter|0|110-preInit
            // write pre-init user code here
            voltarAjudaCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|110-getter|1|110-postInit
            // write post-init user code here
        }//GEN-BEGIN:|110-getter|2|
        return voltarAjudaCommand;
    }
//</editor-fold>//GEN-END:|110-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: ajuda ">//GEN-BEGIN:|108-getter|0|108-preInit
    /**
     * Returns an initialized instance of ajuda component.
     *
     * @return the initialized component instance
     */
    public Form getAjuda() {
        if (ajuda == null) {//GEN-END:|108-getter|0|108-preInit
            // write pre-init user code here
            ajuda = new Form("form");//GEN-BEGIN:|108-getter|1|108-postInit
            ajuda.addCommand(getVoltarAjudaCommand());
            ajuda.setCommandListener(this);//GEN-END:|108-getter|1|108-postInit
            // write post-init user code here
        }//GEN-BEGIN:|108-getter|2|
        return ajuda;
    }
//</editor-fold>//GEN-END:|108-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: configuraçõesCommand ">//GEN-BEGIN:|113-getter|0|113-preInit
    /**
     * Returns an initialized instance of configuraçõesCommand component.
     *
     * @return the initialized component instance
     */
    public Command getConfiguraçõesCommand() {
        if (configuraçõesCommand == null) {//GEN-END:|113-getter|0|113-preInit
            // write pre-init user code here
            configuraçõesCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|113-getter|1|113-postInit
            // write post-init user code here
        }//GEN-BEGIN:|113-getter|2|
        return configuraçõesCommand;
    }
//</editor-fold>//GEN-END:|113-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: voltarConfCommand ">//GEN-BEGIN:|118-getter|0|118-preInit
    /**
     * Returns an initialized instance of voltarConfCommand component.
     *
     * @return the initialized component instance
     */
    public Command getVoltarConfCommand() {
        if (voltarConfCommand == null) {//GEN-END:|118-getter|0|118-preInit
            // write pre-init user code here
            voltarConfCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|118-getter|1|118-postInit
            // write post-init user code here
        }//GEN-BEGIN:|118-getter|2|
        return voltarConfCommand;
    }
//</editor-fold>//GEN-END:|118-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: salvarConfCommand ">//GEN-BEGIN:|122-getter|0|122-preInit
    /**
     * Returns an initialized instance of salvarConfCommand component.
     *
     * @return the initialized component instance
     */
    public Command getSalvarConfCommand() {
        if (salvarConfCommand == null) {//GEN-END:|122-getter|0|122-preInit
            // write pre-init user code here
            salvarConfCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|122-getter|1|122-postInit
            // write post-init user code here
        }//GEN-BEGIN:|122-getter|2|
        return salvarConfCommand;
    }
//</editor-fold>//GEN-END:|122-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: configurações ">//GEN-BEGIN:|115-getter|0|115-preInit
    /**
     * Returns an initialized instance of configurações component.
     *
     * @return the initialized component instance
     */
    public Form getConfigurações() {
        if (configurações == null) {//GEN-END:|115-getter|0|115-preInit
            // write pre-init user code here
            configurações = new Form("Configura\u00E7\u00F5es", new Item[]{getMetaCaloriastextField()});//GEN-BEGIN:|115-getter|1|115-postInit
            configurações.addCommand(getVoltarConfCommand());
            configurações.addCommand(getSalvarConfCommand());
            configurações.setCommandListener(this);//GEN-END:|115-getter|1|115-postInit
            // write post-init user code here
        }//GEN-BEGIN:|115-getter|2|
        return configurações;
    }
//</editor-fold>//GEN-END:|115-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: metaCaloriastextField ">//GEN-BEGIN:|117-getter|0|117-preInit
    /**
     * Returns an initialized instance of metaCaloriastextField component.
     *
     * @return the initialized component instance
     */
    public TextField getMetaCaloriastextField() {
        if (metaCaloriastextField == null) {//GEN-END:|117-getter|0|117-preInit
            // write pre-init user code here
            metaCaloriastextField = new TextField("Meta de calorias di\u00E1rias:", "", 32, TextField.ANY);//GEN-LINE:|117-getter|1|117-postInit
            // write post-init user code here
        }//GEN-BEGIN:|117-getter|2|
        return metaCaloriastextField;
    }
//</editor-fold>//GEN-END:|117-getter|2|

    /**
     * Returns a display instance.
     *
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started. Checks whether the MIDlet have been
     * already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     *
     * @param unconditional if true, then the MIDlet has to be unconditionally
     * terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }
}
